/**
 * 
 */
package com.oscarmovie.action;

import java.util.Date;

import com.oscarmovie.Constants;
import com.oscarmovie.model.DescriptionMovie;
import com.oscarmovie.model.DescriptionPerson;
import com.oscarmovie.model.Movie;
import com.oscarmovie.model.Paging;
import com.oscarmovie.model.Person;
import com.oscarmovie.service.DescriptionService;
import com.oscarmovie.service.MovieService;
import com.oscarmovie.service.PersonService;

public class DescriptionAction {
	
	private DescriptionPerson biography;
	private DescriptionMovie plot;
	
	private DescriptionService descriptionService;
	
	private PersonService personService;
	private MovieService movieService;
	private Paging paging = new Paging(20);
	
	
	public String addBiography() throws Exception{
		biography.setDatetime(new Date());
		descriptionService.save(biography);
		
		Person dbPerson = personService.load(biography.getPerson().getId());
		dbPerson.setBiography(biography.getContent());
		personService.save(dbPerson);
		return Constants.REFRESH;
	}
	
	public String addPlot() throws Exception{
		plot.setDatetime(new Date());
		//descriptionService.save(plot);
		
		Movie dbMovie = movieService.load(plot.getMovie().getId());
		dbMovie.setPlot(plot.getContent());
		movieService.save(dbMovie);
		return Constants.REFRESH;
	}

	public void setBiography(DescriptionPerson biography) {
		this.biography = biography;
	}


	public DescriptionPerson getBiography() {
		return biography;
	}


	public void setPaging(Paging paging) {
		this.paging = paging;
	}


	public Paging getPaging() {
		return paging;
	}


	
	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}


	public PersonService getPersonService() {
		return personService;
	}


	public void setPlot(DescriptionMovie plot) {
		this.plot = plot;
	}


	public DescriptionMovie getPlot() {
		return plot;
	}


	public void setDescriptionService(DescriptionService descriptionService) {
		this.descriptionService = descriptionService;
	}


	public DescriptionService getDescriptionService() {
		return descriptionService;
	}

	public void setMovieService(MovieService movieService) {
		this.movieService = movieService;
	}

	public MovieService getMovieService() {
		return movieService;
	}
	

	
}
